<template>
	<view>
		<view class="cu-modal" :class="modalName=='DialogModal8'?'show':''">
			<view class="cu-dialog set-width">
				<view class="cu-bar justify-end changebgc">
					<view class="content text-white top-title">更换岗位</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-white"></text>
					</view>
				</view>
				<view class="set-padding">
					<view class="flex flex-mine">
						<view class="title-h2">姓名:</view>
						<view class="detail-h2">{{item.name}}</view>
					</view>
					<view class="flex-mine">
						<view class="form-item cu-form-group">
							<view class="title">岗位</view>
							<picker @change="PickerChange1" :value="index1" :range="picker1" range-key="name">
								<view class="picker">
									{{index1>-1?picker1[index1].name:'请选择'}}
								</view>
							</picker>
						</view>
					</view>
				</view>
				<view class="cu-bar bg-white set-bottom">
					<view class="flex">
						<view class="set-btn1" @tap="hideModal">取消</view>
						<view class="cu-btn set-btn2" @tap="handleClickChangePost">确定</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			item: {
				type: Object,
			},
			modalName: {
				type: String,
				default: null,
			}
		},
		methods: {
			// 取token
			getToken() {
				try {
					const value = uni.getStorageSync('login_key');
					if (value) {
						this.token = value;
					}
				} catch (e) {
					// error
				}
			},
			// 点击确定提交
			async handleClickChangePost() {
				// console.log("点击了")
				this.getToken()
				// 发请求
				let url = this.ServicesApi.changePosition;
				let data = {
					position_id: this.position_id, //新选岗位
					position_id_old: this.item.position_id, //原岗位
					jlog_id: this.item.jlog_id, //入职离职记录表id
				};
				let result = await this.Services.post(url, data);
				if (result.code == this.StatusCode.SUCCESS_CODE) {
					this.modalName = null
					this.$parent.getcountTopList();
					this.$parent.getInServiceList();
					uni.showToast({
						icon: 'none',
						title: result.msg
					});
				} else {
					this.leaveMsg = result.msg;
				}
				// uni.request({
				//     url: this.ServicesApi.changePosition, 
				// 	method:'POST',
				// 	header: {
				// 		token:this.token,
				// 		"content-type":"application/x-www-form-urlencoded"
				// 	},
				//     data: {
				// 		position_id:this.position_id,  //新选岗位
				// 		position_id_old:this.item.position_id,  //原岗位
				// 		jlog_id:this.item.jlog_id,  //入职离职记录表id
				//     },
				//     success: (res) => {
				// 		// console.log(res.data)
				// 		if(res.data.code == 0){
				// 			this.leaveMsg = res.data.msg;
				// 			return false
				// 		}else{
				// 			// console.log(res.data);
				// 			this.modalName = null
				// 			this.$parent.getcountTopList();
				// 			this.$parent.getInServiceList();
				// 			uni.showToast({
				// 				title: res.data.msg
				// 			});

				// 		}
				//     }
				// });
			},
		}

	}
</script>

<style scoped lang="stylus">
	.leavemsg {
		height: 30upx;
		font-size: 28upx;
		margin-bottom: 20upx;
		color: red;
	}

	// 放弃入职模态框样式
	.top-title {
		margin-right: 350upx;
		font-size: 28upx;
		font-weight: 400;
		color: rgba(255, 255, 255, 1);
	}

	.set-width {
		width: 540upx;
	}

	.set-padding {
		padding: 30upx 28upx 30upx 30upx;
	}

	.changebgc {
		background: #4A90E2;
		height: 70upx !important;
	}

	.flex-mine {
		margin-bottom: 30upx;
		align-items: center;
	}

	.title-h2 {
		font-size: 30upx;
		color: #666;
	}

	.detail-h2 {
		text-align: left;
		font-size: 30upx;
		color: #333;
		font-weight: 400;
	}

	.inp-model {
		height: 60upx;
		width: 318upx;
		background: #F3F3F3;
		line-height: 60upx;
		justify-content: space-between;
		padding: 0 26upx;
		font-size: 30upx;
		color: #333;
	}

	.set-bottom {
		height: 92upx;
		line-height: 92upx;
	}

	.set-btn1 {
		height: 92upx;
		line-height: 92upx;
		background: #fff;
		border-right: 1px solid #D8D8D8;
		border-top: 1px solid #D8D8D8;
		width: 270upx;
		font-size: 30upx;
		text-align: center;
		color: #333;
	}

	.set-btn2 {
		height: 92upx;
		line-height: 92upx;
		background: #fff;
		width: 268upx;
		border-top: 1px solid #D8D8D8;
		font-size: 30upx;
		text-align: center;
		color: #4A90E2;
	}
</style>
